package com.ipemon.model;

import java.util.Random;

public class Foret {

	private int ipemonCounter = 1;
	
	public IPemon generateIpemon() {
		
		Random random = new Random();
		
		IPemon ipemon = new IPemon();
		
		ipemon.setIdentifiant(ipemonCounter++);
		ipemon.setEspece(random.nextInt(12));
		ipemon.setVieCur(30+random.nextInt(50));
		ipemon.setVieMax(80+random.nextInt(20));
		ipemon.setExperience(random.nextInt(10));
		ipemon.setRapidite(random.nextInt(10));
		
		Power attaque = new Power();
		attaque.setAir(random.nextInt(11));
		attaque.setEau(random.nextInt(11));
		attaque.setElectric(random.nextInt(11));
		attaque.setFeu(random.nextInt(11));
		attaque.setPierre(random.nextInt(11));
		attaque.setPlante(random.nextInt(11));
		
		ipemon.setAttaque(attaque);
		
		Power defense = new Power();
		
		defense.setAir(attaque.getPierre());
		defense.setEau(attaque.getFeu());
		defense.setElectric(attaque.getPlante());
		defense.setPlante(attaque.getElectric());
		defense.setPierre(attaque.getAir());
		defense.setFeu(attaque.getEau());
		
		ipemon.setDefense(defense);
		return ipemon;
	}
	
	public String getIpemonStream(IPemon ipemon) {
		
		String ipemonStr = "";
		
		ipemonStr += String.valueOf(ipemon.getIdentifiant()) + ":";
		ipemonStr += String.valueOf(ipemon.getEspece()) + ":";
		ipemonStr += String.valueOf(ipemon.getVieCur()) + ":";
		ipemonStr += String.valueOf(ipemon.getVieMax()) + ":";
		ipemonStr += String.valueOf(ipemon.getExperience()) + ":";
		ipemonStr += String.valueOf(ipemon.getRapidite()) + ":(";
		
		ipemonStr += String.valueOf(ipemon.getAttaque().getFeu()) + ":";
		ipemonStr += String.valueOf(ipemon.getAttaque().getEau()) + ":";		
		ipemonStr += String.valueOf(ipemon.getAttaque().getElectric()) + ":";		
		ipemonStr += String.valueOf(ipemon.getAttaque().getPlante()) + ":";		
		ipemonStr += String.valueOf(ipemon.getAttaque().getAir()) + ":";		
		ipemonStr += String.valueOf(ipemon.getAttaque().getPierre()) + "):(";		
		
		ipemonStr += String.valueOf(ipemon.getDefense().getFeu()) + ":";	
		ipemonStr += String.valueOf(ipemon.getDefense().getEau()) + ":";	
		ipemonStr += String.valueOf(ipemon.getDefense().getElectric()) + ":";	
		ipemonStr += String.valueOf(ipemon.getDefense().getPlante()) + ":";	
		ipemonStr += String.valueOf(ipemon.getDefense().getAir()) + ":";	
		ipemonStr += String.valueOf(ipemon.getDefense().getPierre()) + ")";	
		
		return ipemonStr;
	}
	
	public void displayIPemon(IPemon ipemon) {
		
		System.out.println("IPemon:\t\t" + ipemon.getIdentifiant() + " [" + ipemon.getEspece() + "]");
		System.out.println("Vie: \t\t" + ipemon.getVieCur() + "/" + ipemon.getVieMax());
		System.out.println("Rapidity: \t" + ipemon.getRapidite());
		System.out.println("Experience: \t" + ipemon.getExperience());

		System.out.println("\t\t" + "Feu\t" + "Eau\t" + "Elect\t" + "Plante\t" + "Air\t" + "Pierre");
		System.out.println("Attaque\t\t" + ipemon.getAttaque().getFeu() + "\t" + ipemon.getAttaque().getEau() + "\t" +
							ipemon.getAttaque().getElectric() + "\t" + ipemon.getAttaque().getPlante() + "\t" + 
							ipemon.getAttaque().getAir() + "\t" + ipemon.getAttaque().getPierre() + "\t");
		System.out.println("Defense\t\t" + ipemon.getDefense().getFeu() + "\t" + ipemon.getDefense().getEau() + "\t" +
				ipemon.getDefense().getElectric() + "\t" + ipemon.getDefense().getPlante() + "\t" + 
				ipemon.getDefense().getAir() + "\t" + ipemon.getDefense().getPierre() + "\t");
		
	}
	
	public static void main(String[] args) {
	
		
		
		Foret foret = new Foret();

		foret.displayIPemon(foret.generateIpemon());
		
//		System.out.println(foret.getIpemonStream(foret.generateIpemon()));
//		System.out.println(foret.getIpemonStream(foret.generateIpemon()));
//		System.out.println(foret.getIpemonStream(foret.generateIpemon()));
//		System.out.println(foret.getIpemonStream(foret.generateIpemon()));
		
	
	}
	
}
